package modules.user.entity;

import java.util.Date;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Table;

import org.hibernate.annotations.Cache;
import org.hibernate.annotations.CacheConcurrencyStrategy;

/**
 * 用户信息
 *
 * @author langhsu
 * CacheConcurrencyStrategy:缓存并发性策略，采用了非严格性读写。参考：
 * https://www.jianshu.com/p/6f357c4cc0f7
 * 
 * 
 */
@Entity
@Table(name="mto_users")
@Cache(usage=CacheConcurrencyStrategy.NONSTRICT_READ_WRITE)
public class User {
	@Id//主键
	@GeneratedValue(strategy=GenerationType.IDENTITY)//制定主键自增的方式，这里采用数据库自增
	private long id;
	
	/**
	 * @Column,用来标识实体类中属性与数据表中字段的对应关系
	 * name:定义了被标注字段在数据库表中所对应字段的名称；
	 * unique:表示该字段是否为唯一标识，默认为false。（就是username这个字段每条记录都要唯一，不能相同）
	 * length：表示字段的长度，当字段的类型为varchar时，该属性才有效，默认为255个字符
	 */
	@Column(name="username",unique=true,length=64)
	private String username;// 用户名
	
	@Column(name="password",length=64)
	private String password;// 密码
	
	private String avatar;// 头像
	
	@Column(name="name",length=18)
	private String name;// 昵称
	
	private int gender;// 性别
	
	@Column(name="email",unique=true,length=128)
	private String email;// 邮箱
	
	@Column(name="mobile",length=11)
	private String mobile;// 手机号
	
	private int posts;// 文章数
	
	private int comments;// 发布评论数
	
	private int follows;// 关注人数
	
	private int fans;// 粉丝数
	
	private int favors;// 收到的喜欢数
	
	private Date created;// 注册时间
	
	private int source;// 注册来源：主要用于区别第三方登录
	
	@Column(name="last_login")
	private Date lastLogin;
	
	private String signature;// 个性签名
	
	@Column(name="active_email")
	private int activeEmail;// 邮箱激活状态
	
	private int status;// 用户状态
	
	public User() {

	}

	public User(long id) {
		this.id = id;
	}

	public long getId() {
		return id;
	}

	public void setId(long id) {
		this.id = id;
	}

	public String getUsername() {
		return username;
	}

	public void setUsername(String username) {
		this.username = username;
	}

	public String getPassword() {
		return password;
	}

	public void setPassword(String password) {
		this.password = password;
	}

	public String getAvatar() {
		return avatar;
	}

	public void setAvatar(String avatar) {
		this.avatar = avatar;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public int getGender() {
		return gender;
	}

	public void setGender(int gender) {
		this.gender = gender;
	}

	public String getEmail() {
		return email;
	}

	public void setEmail(String email) {
		this.email = email;
	}

	public String getMobile() {
		return mobile;
	}

	public void setMobile(String mobile) {
		this.mobile = mobile;
	}

	public int getPosts() {
		return posts;
	}

	public void setPosts(int posts) {
		this.posts = posts;
	}

	public int getComments() {
		return comments;
	}

	public void setComments(int comments) {
		this.comments = comments;
	}

	public int getFollows() {
		return follows;
	}

	public void setFollows(int follows) {
		this.follows = follows;
	}

	public int getFans() {
		return fans;
	}

	public void setFans(int fans) {
		this.fans = fans;
	}

	public int getFavors() {
		return favors;
	}

	public void setFavors(int favors) {
		this.favors = favors;
	}

	public Date getCreated() {
		return created;
	}

	public void setCreated(Date created) {
		this.created = created;
	}

	public int getSource() {
		return source;
	}

	public void setSource(int source) {
		this.source = source;
	}

	public Date getLastLogin() {
		return lastLogin;
	}

	public void setLastLogin(Date lastLogin) {
		this.lastLogin = lastLogin;
	}

	public String getSignature() {
		return signature;
	}

	public void setSignature(String signature) {
		this.signature = signature;
	}

	public int getActiveEmail() {
		return activeEmail;
	}

	public void setActiveEmail(int activeEmail) {
		this.activeEmail = activeEmail;
	}

	public int getStatus() {
		return status;
	}

	public void setStatus(int status) {
		this.status = status;
	}
	
	
	
}
